home *** CD-ROM | disk | FTP | other *** search
- //------------------------------------------------------------------------------
- //
- // ADOBE SYSTEMS INCORPORATED
- // Copyright 2000-2002 Adobe Systems Incorporated
- // All Rights Reserved
- //
- // NOTICE: Adobe permits you to use, modify, and distribute
- // this file in accordance with the terms of the Adobe license
- // agreement accompanying it. If you have received this file
- // from a source other than Adobe, then your use, modification,
- // or distribution of it requires the prior written permission
- // of Adobe.
- //
- //------------------------------------------------------------------------------
-
-
- //----------------------------------------------------
- // parse functions:
- //
- // Description:
- // Called by parseBox() for each custom box.
- // Display error message if box inserted in
- // incorrect location.
- // Set and create links on the box.
-
- function parseA(box, reason)
- {
- if (!document) {
- // there should always be a document
- // since the custom box is drawn in a document
- return;
- }
- var version = getWMLVersion(document);
-
- box.ctlAhref = (box.element.href) ?
- box.createLink (box.element.href) :
- box.createLink (settings.masterPrefs.emptyReferenceName);
- if (checkPositionForAnchorAndA(box.element, version) < 0) {
- if (version == "1.1") {
- alert(module.localize("A must be inside Fieldset, P, Strong, Em, B, I, or U."));
- }
- else {
- alert(module.localize("A must be inside Fieldset, P, Pre, Strong, Em, B, I, or U."));
- }
- }
- }
-
- function parseAnchor(box, reason)
- {
- if (!document) {
- // there should always be a document
- // since the custom box is drawn in a document
- return;
- }
- var version = getWMLVersion(document);
-
- if (checkPositionForAnchorAndA(box.element, version) < 0) {
- if (version == "1.1") {
- alert(module.localize("Anchor must be inside Fieldset, P, Strong, Em, B, I, or U."));
- }
- else {
- alert(module.localize("Anchor must be inside Fieldset, P, Pre, Strong, Em, B, I, or U."));
- }
- }
- }
-
- function parseCard(box,reason)
- {
- box.onenterforward = (box.element.onenterforward) ?
- box.createLink(box.element.onenterforward) :
- box.createLink(settings.masterPrefs.emptyReferenceName);
- box.onenterbackward = (box.element.onenterbackward) ?
- box.createLink (box.element.onenterbackward) :
- box.createLink(settings.masterPrefs.emptyReferenceName);
- box.ontimer = (box.element.ontimer) ?
- box.createLink (box.element.ontimer) :
- box.createLink(settings.masterPrefs.emptyReferenceName);
- // fill in id attribute if undefined
- if (box.element.id == undefined) {
- box.element.setAttribute("id", "C" + Math.random().toString().substring(2));
- }
- //check to see if the box is attached to the correct
- //parent element only on drag and drop
- if (reason == 2 || reason == 3){
- var errVal = checkPositionForCard(box.element);
- if (errVal == c_parentWrong) {
- alert (module.localize("Card must be inside the WML deck."));
- }
- else if (errVal == c_previousWrong) {
- alert(module.localize("Card inserted in wrong position."));
- }
- }
- }
-
- function parseDo(box, reason)
- {
- if (!document) {
- // there should always be a document
- // since the custom box is drawn in a document
- return;
- }
- var version = getWMLVersion(document);
-
- if (reason == 2 || reason == 3) {
- if (checkPositionForDo(box.element, version) < 0) {
- if (version == "1.1") {
- alert(module.localize("Do must be inside Card, Fieldset, P, or Template."));
- }
- else {
- alert(module.localize("Do must be inside Card, Fieldset, P, Pre, or Template."));
- }
- }
- }
- }
-
- function parseFieldset(box, reason)
- {
- if (reason == 2 || reason == 3){
- if (checkPositionForFieldset(box.element) < 0) {
- alert(module.localize("Fieldset must be inside Fieldset or P."));
- }
- }
- }
-
- function parseGo(box, reason)
- {
- box.ctlGoHref = (box.element.href) ?
- box.createLink (box.element.href) :
- box.createLink(settings.masterPrefs.emptyReferenceName);
- if (reason == 2 || reason == 3) {
- var errVal = checkPositionForGoPrevAndRefresh(box.element);
- if (errVal == c_parentWrong) {
- alert(module.localize("Go must be inside Do, Onevent or Anchor."));
- }
- else if (errVal < 0) {
- alert(module.localize("Go inserted in wrong position."));
- }
- }
- }
-
- function parseImg(box, reason)
- {
- box.ctlImgsrc = (box.element.src) ?
- box.createLink (box.element.src) :
- box.createLink (settings.masterPrefs.emptyReferenceName);
- if (reason == 2 || reason == 3){
- if (checkPositionForImg(box.element) < 0) {
- alert(module.localize("Image must be inside Fieldset, A, Anchor, P, Em, Strong, B, I, or U."));
- }
- }
- }
-
- function parseInput(box, reason)
- {
- if (!document) {
- // there should always be a document
- // since the custom box is drawn in a document
- return;
- }
- var version = getWMLVersion(document);
-
- if (reason == 2 || reason == 3){
- var errVal = checkPositionForInputAndSelect(box.element, version);
- if (errVal == c_parentWrong) {
- if (version == "1.1") {
- alert(module.localize("Input must be inside Fieldset, or P."));
- }
- else {
- alert(module.localize("Input must be inside Fieldset, P, or Pre."));
- }
- }
- else if (errVal < 0) { // should not happen
- alert(module.localize("Input inserted in wrong position."));
- }
- }
- }
-
- function parseNoop(box, reason)
- {
- if (reason == 2 || reason == 3) {
- var errVal = checkPositionForNoop(box.element);
- if (errVal == c_parentWrong) {
- alert(module.localize("Noop must be inside Do or Onevent."));
- }
- else if (errVal < 0) {
- alert(module.localize("Noop inserted in wrong position."));
- }
- }
- }
-
- function parseOnevent(box, reason)
- {
- if (reason == 2 || reason == 3) {
- var errVal = checkPositionForOnevent(box.element);
- if (errVal == c_parentWrong) {
- alert(module.localize("Onevent must be inside Card, Template or Option."));
- }
- else if (errVal < 0) {
- alert(module.localize("Onevent inserted in wrong position."));
- }
- }
- }
-
-
- function parseOption(box, reason)
- {
- if (reason == 2 || reason == 3) {
- if (checkPositionForOption(box.element) < 0) {
- alert(module.localize("Option must be inside Select or Optgroup."));
- }
- }
- }
-
- function parseOptiongroup(box, reason)
- {
- if (reason == 2 || reason == 3){
- if (checkPositionForOptgroup(box.element) < 0) {
- alert(module.localize("Optgroup must be inside Select."));
- }
- }
- }
-
- function parsePostfield(box, reason)
- {
- if (reason == 2 || reason == 3) {
- if (checkPositionForPostfield(box.element) < 0) {
- alert(module.localize("Postfield must be inside Go."));
- }
- }
- }
-
- function parsePre(box, reason)
- {
- if (!document) {
- // there should always be a document
- // since the custom box is drawn in a document
- return;
- }
- var version = getWMLVersion(document);
-
- if (reason == 2 || reason == 3) {
- var errVal = checkPositionForPre(box.element, version);
- if (errVal == c_versionWrong) {
- alert(module.localize("Pre not allowed in WML 1.1 document."));
- }
- else if (errVal == c_parentWrong) {
- alert(module.localize("Pre must be inside Card."));
- }
- else if (errVal < 0) {
- alert(module.localize("Pre inserted in wrong position."));
- }
- }
- }
-
- function parsePrev(box, reason)
- {
- if (reason == 2 || reason == 3) {
- var errVal = checkPositionForGoPrevAndRefresh(box.element);
- if (errVal == c_parentWrong) {
- alert(module.localize("Prev must be inside Do, Onevent or Anchor."));
- }
- else if (errVal < 0) {
- alert(module.localize("Prev inserted in wrong position."));
- }
- }
- }
-
- function parseRefresh(box, reason)
- {
- if (reason == 2 || reason == 3) {
- var errVal = checkPositionForGoPrevAndRefresh(box.element);
- if (errVal == c_parentWrong) {
- alert(module.localize("Refresh must be inside Do, Onevent or Anchor."));
- }
- else if (errVal < 0) {
- alert(module.localize("Refresh inserted in wrong position."));
- }
- }
- }
-
- function parseSelect(box, reason)
- {
- if (!document) {
- // there should always be a document
- // since the custom box is drawn in a document
- return;
- }
- var version = getWMLVersion(document);
-
- if (reason == 2 || reason == 3) {
- if (checkPositionForInputAndSelect(box.element, version) < 0) {
- if (version == "1.1") {
- alert(module.localize("Select must be inside Fieldset, or P."));
- }
- else {
- alert(module.localize("Select must be inside Fieldset, P, or Pre."));
- }
- }
- }
- }
-
- function parseSetvar(box, reason)
- {
- if (reason == 2 || reason == 3) {
- if (checkPositionForSetvar(box.element) < 0) {
- alert(module.localize("Setvar must be inside Go, Prev, or Refresh."));
- }
- }
- }
-
- function parseTemplate(box, reason){
- box.ctlTemplateOnEnterForward = (box.element.onenterforward) ?
- box.createLink (box.element.onenterforward) :
- box.createLink (settings.masterPrefs.emptyReferenceName);
- box.ctlTemplateOnEnterBackward = (box.element.onenterbackward) ?
- box.createLink (box.element.onenterbackward) :
- box.createLink (settings.masterPrefs.emptyReferenceName);
- box.ctlTemplateOnTimer = (box.element.ontimer) ?
- box.createLink (box.element.ontimer) :
- box.createLink (settings.masterPrefs.emptyReferenceName);
-
- if (reason == 2 || reason == 3) {
- var i = checkPositionForTemplate(box.element);
- if (i == c_parentWrong) {
- alert (module.localize("Template must be inside the WML deck."));
- }
- else if (i == c_previousWrong) {
- alert(module.localize("Template must be first in the WML deck."));
- }
- }
- }
-
- function parseTimer(box, reason)
- {
- if (reason == 2 || reason == 3){
- var errVal = checkPositionForTimer(box.element);
- if (errVal == c_parentWrong) {
- alert(module.localize("Timer must be inside Card."));
- }
- else if (errVal < 0) {
- alert(module.localize("Timer inserted in wrong position."));
- }
- }
- }